package com.chuantou.yuba.ui.fragment;

import com.chuantou.yuba.R;
import com.chuantou.yuba.util.FragmentUtil;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class HomeTrendsFragment extends BaseFragment {
	private View mContentView;

	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		if (mContentView == null) {
			mContentView = inflater.inflate(R.layout.fg_follow_trends, null);
		}
		ViewGroup parentView = (ViewGroup) mContentView.getParent();
		if (parentView != null) {
			parentView.removeView(mContentView);
		}
		FragmentManager fragmentManager = getChildFragmentManager();
		String fragmentName = FollowTrendsFragment.class.getName();
		Fragment fragment = fragmentManager.findFragmentByTag(fragmentName);
		FragmentTransaction transaction = fragmentManager.beginTransaction();
		if (fragment == null) {
			fragment = Fragment.instantiate(getActivity(), fragmentName);
			transaction.add(R.id.trends_content, fragment, fragmentName);
		} else {
			transaction.show(fragment);
		}
		transaction.commitAllowingStateLoss();
		return mContentView;
	}
}
